<?php

namespace app\admin\model\wanlshop;

use app\admin\model\User;
use think\Model;


class Lifeend extends Model
{

    

    

    // 表名
    protected $name = 'wanlshop_lifeend';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;
    protected $type = [
        'data' => 'json'
    ];
    // 追加属性
    protected $append = [
        'status_text'
    ];
    

    
    public function getStatusList()
    {
        return ['created' => __('Created'), 'successed' => __('Successed'), 'rejected' => __('Rejected')];
    }
    public function getPaymentStatusList()
    {
        return ['0' => __('Payment_status 0'), '1' => __('Payment_status 1'), '2' => __('Payment_status 2'), '3' => __('Payment_status 3'), '4' => __('Payment_status 4')];
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }



    public function user()
    {
        return $this->belongsTo(User::class, 'user_id', 'id');
    }
}
